package com.xly.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xly.entity.MedicalRecord;
import com.xly.service.MedicalRecordServcie;
import com.xly.util.JsonUtil;

/** 
* @author Your-Name: Carey
* @version Create-Date：2020年3月18日 下午5:45:06 
* Class Description:
*/
@RestController
@RequestMapping("/med")
public class MedicalRecordController {

	@Autowired
	private MedicalRecordServcie medicalRecordServcie;
	
	//条件查询
	@RequestMapping(value="/getList",produces="text/html;charset=UTF-8")
	public JsonUtil getList(MedicalRecord medicalRecord) {
		List<MedicalRecord> list = medicalRecordServcie.selectCondition(medicalRecord);
		return JsonUtil.success(list);
	}
	
	//批量删除
	@RequestMapping(value="/deleteBatch",produces="text/html;charset=UTF-8")
	public boolean deleteBatch(int[] ids) {
		int i = medicalRecordServcie.deleteBatch(ids);
		if(i>0) {
			return true;
		}
		return false;
	}
	
	//批量删除
	@RequestMapping(value="/getDetail",produces="text/html;charset=UTF-8")
	public JsonUtil getDetail(int id) {
		MedicalRecord medicalRecord = medicalRecordServcie.selectById(id);
		return JsonUtil.success(medicalRecord);
	}
	
	//新增
	@RequestMapping(value="/add",produces="text/html;charset=UTF-8")
	public boolean add(MedicalRecord medicalRecord) {
		int i = medicalRecordServcie.insertEntity(medicalRecord);
		if(i>0) {
			return true;
		}
		return false;
	}
	
	//新增
	@RequestMapping(value="/updateById",produces="text/html;charset=UTF-8")
	public boolean updateById(MedicalRecord medicalRecord) {
		int i = medicalRecordServcie.updateById(medicalRecord);
		if(i>0) {
			return true;
		}
		return false;
	}
}
